<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
        <span aria-hidden="true">&times;</span></button>
    <h4 class="modal-title">权限信息</h4>
</div>
<div class="modal-body">
    <div class="form-horizontal row">
        <form id="form-data" >
            <div id="div_error" class="col-sm-12"></div>
            <input type="hidden" id="id" name="id" value="${data.id}">
            <div class="form-group col-sm-6">
                <label class="control-label col-sm-4"><s>*</s>名称：</label>
                <div class="col-sm-6">
                    <input type="text" class="form-control" name="name" value="${data.name}">
                </div>
            </div>
            <div class="form-group col-sm-6">
                <label class="col-sm-4 control-label"><s>*</s>类型：</label>
                <div class="col-sm-6">
                    <select id="type" class="form-control" name="type">
                        <option value="">&nbsp;</option>
                    </select>
                </div>
            </div>

            <div class="form-group col-sm-6">
                <label class="col-sm-4 control-label"><s>*</s>状态：</label>
                <div class="col-sm-6">
                    <select id="live" class="form-control" name="live">
                        <option value="">&nbsp;</option>
                    </select>
                </div>
            </div>
            <div class="form-group col-sm-6">
                <label class="col-sm-4 control-label">序号：</label>
                <div class="col-sm-6">
                    <input type="number" class="form-control" name="orders" value="${data.orders}">
                </div>
            </div>

            <div class="form-group col-sm-6">
                <label class="control-label col-sm-4">图标：</label>
                <div class="col-sm-6">
                    <input type="text" class="form-control" name="icon" value="${data.icon}">
                </div>
            </div>

            <div class="form-group col-sm-6">
                <label class="control-label col-sm-4">路径：</label>
                <div class="col-sm-6">
                    <input type="text" class="form-control" name="url" value="${data.url}">
                </div>
            </div>

            <div class="form-group col-sm-6">
                <label class="control-label col-sm-4">入口权值：</label>
                <div class="col-sm-6">
                    <input type="text" class="form-control" name="permission" value="${data.permission}">
                </div>
            </div>

            <div class="form-group col-sm-6">
                <label class="control-label col-sm-4">父亲：</label>
                <div class="col-sm-6">
                    <input type="text" class="form-control" name="pid" value="${data.pid}">
                </div>
            </div>

            <div class="form-group col-sm-6">
                <label class="control-label col-sm-4">备注：</label>
                <div class="col-sm-6">
                    <input type="text" class="form-control" name="remark" value="${data.remark}">
                </div>
            </div>


            <div class="form-group col-sm-6">
                <div class="col-sm-6 col-sm-offset-4">
                    <button type="submit"
                            class="btn btn-default btn-success"><span
                            class="glyphicon glyphicon-ok"></span>&nbsp;确&nbsp;定&nbsp;
                    </button>
                </div>
            </div>

            <div class="form-group col-sm-6">
                <label class="control-label col-sm-4">依赖权值：</label>
                <div class="col-sm-8">
                    <textarea rows="5" type="text" class="form-control" name="requestPermission">${data.requestPermission}</textarea>
                </div>
            </div>
        </form>
    </div>
</div>
<script>

    $.sysPlugin.initSelect2($("#live"), {
        data: $.sysPlugin.enumeration.live,
        value: '${data.live}'
    });
    $.sysPlugin.initSelect2($("#type"), {
        data: {0:'菜单',1:'按钮'},
        value: '${data.type}'
    });

    <%--bootstrapValidator--%>
    var $form = $("#form-data");
    $form.bootstrapValidator({
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
            name: {
                validators: {
                    notEmpty: {
                        message: '不能为空！'
                    }
                }
            },
            type: {
                validators: {
                    notEmpty: {
                        message: '不能为空！'
                    }
                }
            },
            live: {
                validators: {
                    notEmpty: {
                        message: '不能为空！'
                    }
                }
            }
        }
    }).on('success.form.bv', function (e) {
        e.preventDefault();

        $.sysPlugin.superAjax({
            data: $(e.target).serialize(),
            url: '${url}',
            operateType: '${operateType}',
            showSuccessAlert: true,
            showWarnAlert: false,
            successCall: function (data) {
                $.sysPlugin.successCallBack(data, {
                    modal: $("#modal_ajax"),
                    table: $("#table_data")
                })
            },
            errorCall: function (data) {
                $.sysPlugin.errorCallBack(data, {
                    errorAddress: $("#div_error"),
                    form: $form
                })
            }
        })
    });

</script>
